# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  #layout "student_layout"
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_PaperShelf_session_id'
  
  private
  
  
  
  def authorize_admin
    unless session[:user_type]=="administrator"
      flash[:notice] = "Please log in!!"
      redirect_to( :controler=>"login",:action => "login")
    end
  end
  
  def redirect_to_index(msg = nil)
    flash[:notice] = msg if msg
    redirect_to(:action => 'index')
  end
  
   def authorize
    unless User.find_by_account(session[:account])
      flash[:notice] = "Please log in"
      redirect_to(:controller => "login", :action => "login")
    end
  end
  def pages_for(size, options = {})
  default_options = {:per_page => 10}
  options = default_options.merge options
  pages = Paginator.new self, size, options[:per_page], (params[:page]||1)
  return pages
end 
end
